<?php
if (!isset($_SESSION)){
		session_start();
	}
	$id_orcamento = $_SESSION["id_orcamento"];
	include_once "BudgetControl.php";
	$listaProdutos = BudgetControl::getOrcamentoById($id_orcamento);
	foreach($listaProdutos as $p){
		
		if($p->Fotos[0] != null){
			$file = "imagensBanco/photo".$p->Id."". $p->Fotos[0][1];
			if(file_exists($file)) @unlink($file);
			$fp = fopen($file, "a");
			$escreve = fwrite($fp, $p->Fotos[0][0]);
			fclose($fp);
		}
		else
			$file = "imagensBanco/imagemIndisponivel.bmp";
			$categorias = implode(', ', $p->Categoria);
		
		echo"<tr class=\"row\">";
           	echo"<td class=\"table-column include\"><input type=\"checkbox\" name='checkbox".$p->Id."'></td>";
			echo"<td class=\"table-column description\"><span class=\"product-name\">" . $p->Nome . "</span><span class=\"product-categories\">" . $categorias . "</span></td>";
			echo"<td class=\"table-column column-photo\"><img class=\"photo\" src=\"" . $file . "\"/></td>";
			echo"<td class=\"table-column amount\"><input type=\"number\" value=\"". $p->Quantidade . "\" name='quantidade".$p->Id."'/></td>";
			echo"<td class=\"table-column single-price\"><input type=\"number format\" value=\"" . $p->UltimoPreco . "\" name='preco".$p->Id."'></td>";		
		echo"</tr>";
	}
	
	
?>
